package com.houger.ddd.seckill.constant;

import java.util.Arrays;

/**
 * @author Houger.
 * @date 2024年05月18日 14:04.
 */
public enum ActivityTypeEnum {
    INVITATION(1,"秒杀","com.houger.ddd.seckill.domian.SeckillTemplate"),
    //为了兼容以前的4
    UNKNOW(0, "未知","");

    private Integer type;
    private String desc;
    private String templateTypeClass;

    ActivityTypeEnum(Integer type, String desc, String templateTypeClass) {
        this.type = type;
        this.desc = desc;
        this.templateTypeClass = templateTypeClass;
    }

    public Integer getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public String getTemplateTypeClass() {
        return templateTypeClass;
    }

    public static ActivityTypeEnum getEnumByType(Integer type) {
        return Arrays.stream(ActivityTypeEnum.values()).filter(a -> a.type.equals(type)).findFirst().orElse(UNKNOW);
    }

    public static ActivityTypeEnum getEnumTemplateTypeClass(String typeClass) {
        return Arrays.stream(ActivityTypeEnum.values()).filter(a -> a.templateTypeClass.equals(typeClass)).findFirst().orElse(UNKNOW);
    }
}
